#include "sumservice.h"

SumService::SumService()
{
}

QByteArray SumService::execute (QDataStream &in)
{
    QByteArray block;
    QDataStream out(&block, QIODevice::WriteOnly);

    QString requestType;

    in >> requestType;

    if(requestType == "SUM")
    {
        int num1;
        int num2;

        in >> num1 >> num2;
        out << quint16(0) << QString("RESULT") << (num1 + num2);
        out.device()->seek(0);
        out << quint16(block.size() - sizeof(quint16));
    }
    return block;

}
